﻿using System;
using log4net;

namespace PlayLog4Net
{
    static class TestLogger
    {
        private static void Check(string loggerName)
        {
            ILog logger = LogManager.GetLogger(loggerName);
            logger.PrintDebug(6);
        }

        public static void TestMain()
        {
            // chekanote: I am not sure whether the order of "GetLogger" and "Configure()" matters
            // but I think first "Configure()" and then "GetLogger" would be a good practice
            ILog logger = LogManager.GetLogger("TestLogger");
            System.Diagnostics.Debug.Assert(logger != null);

            log4net.Config.XmlConfigurator.Configure();

            // if logger name exists, then fetch configuration from file
            Console.WriteLine("#################### Log with existing logger name.");
            Check("TestLogger");

            // if logger name DOESN'T exist, then create a new logger with ROOT configuration
            Console.WriteLine("#################### Log with non-existing logger name, use ROOT configuration");
            Check("NoSuchLogger");
        }// TestMain
    }
}
